package handlers

import (
	"app-pub-sys/models"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"net/http"
	"strconv"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	count, _ := strconv.Atoi(c.PostForm("count"))
	types := c.PostForm("types")
	app := models.App{
		Model: gorm.Model{},
		Name:  name,
		Count: count,
		Types: types,
	}
	err := models.DB.Create(&app).Error
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 0,
			"msg":  "发布失败",
		})
		return
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "发布成功",
		})
	}
}
func List(c *gin.Context) {

}
